package com.seed.bpmn.engine.common.util;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;

/**
 * <p>json对象映射工厂</p>
 *
 * @author cscz89@126.com
 */
public class JsonObjectMapperFactory {

    private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
    private static ObjectMapper om = new ObjectMapper();

    static {
        om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        om.setDateFormat(new SimpleDateFormat(DATE_FORMAT));
    }

    @JsonIgnoreProperties("centFactor")
    interface IgnoreMoneySetAmountBigDecimal {
        @JsonIgnore
        void setAmount(BigDecimal amount);
    }

    public static ObjectMapper getInstance() {
        return om;
    }
}
